#ifndef FIXED_E906P_H
#define FIXED_E906P_H

#undef MIN16
static OPUS_INLINE opus_val16 MIN16_e906p(opus_val32 a, opus_val32 b)
{
  opus_val16 __result;

  __asm__(
      "#MIN16\n\t"
      "minw %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MIN16(a, b) (MIN16_e906p(a, b))
/**/
#undef MAX16
static OPUS_INLINE opus_val16 MAX16_e906p(opus_val32 a, opus_val32 b)
{
  opus_val16 __result;

  __asm__(
      "#MAX16\n\t"
      "maxw %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MAX16(a, b) (MAX16_e906p(a, b))

#undef MIN32
static OPUS_INLINE opus_val32 MIN32_e906p(opus_val32 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#MIN32\n\t"
      "minw %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MIN32(a, b) (MIN32_e906p(a, b))

#undef MAX32
static OPUS_INLINE opus_val32 MAX32_e906p(opus_val32 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#MAX32\n\t"
      "maxw %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MAX32(a, b) (MAX32_e906p(a, b))

#undef IMIN
static OPUS_INLINE opus_val32 IMIN_e906p(opus_val32 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#IMIN\n\t"
      "minw %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define IMIN(a, b) (IMIN_e906p(a, b))

#undef IMAX
static OPUS_INLINE opus_val32 IMAX_e906p(opus_val32 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#IMAX\n\t"
      "maxw %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define IMAX(a, b) (IMAX_e906p(a, b))
/*
#undef SAT16
static OPUS_INLINE opus_val16 SAT16_e906p(opus_val32 a)
{
  opus_val16 __result;

  __asm__(
      "#SAT16\n\t"
      "sclip32 %0, %1, 15\n\t"
      : "=r"(__result)
      : "r"(a)
  );
  return __result;
}
#define SAT16(a) (SAT16_e906p(a))

#undef ABS16
static OPUS_INLINE opus_val16 ABS16_e906p(opus_val16 a)
{
  opus_val16 __result;

  __asm__(
      "#ABS16\n\t"
      "kabsw %0, %1\n\t"
      : "=r"(__result)
      : "r"(a)
  );
  return __result;
}
#define ABS16(a) (ABS16_e906p(a))

#undef ABS32
static OPUS_INLINE opus_val32 ABS32_e906p(opus_val32 a)
{
  opus_val32 __result;

  __asm__(
      "#ABS32\n\t"
      "kabsw %0, %1\n\t"
      : "=r"(__result)
      : "r"(a)
  );
  return __result;
}
#define ABS32(a) (ABS32_e906p(a))*/

#undef MULT16_32_Q16
static OPUS_INLINE opus_val32 MULT16_32_Q16_e906p(opus_val16 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#MULT16_32_Q16\n\t"
      "smmwb %0, %2, %1\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MULT16_32_Q16(a, b) (MULT16_32_Q16_e906p(a, b))

#undef MULT16_32_P16
static OPUS_INLINE opus_val32 MULT16_32_P16_e906p(opus_val16 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#MULT16_32_P16\n\t"
      "smmwb.u %0, %2, %1\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MULT16_32_P16(a, b) (MULT16_32_P16_e906p(a, b))

#undef MULT16_32_Q15
static OPUS_INLINE opus_val32 MULT16_32_Q15_e906p(opus_val16 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#MULT16_32_Q15\n\t"
      "kmmwb2 %0, %2, %1\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MULT16_32_Q15(a, b) (MULT16_32_Q15_e906p(a, b))

#undef MULT32_32_Q31
static OPUS_INLINE opus_val32 MULT32_32_Q31_e906p(opus_val32 a, opus_val32 b)
{
  opus_val32 __result;

  __asm__(
      "#MULT32_32_Q31\n\t"
      "kwmmul %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(b)
  );
  return __result;
}
#define MULT32_32_Q31(a, b) (MULT32_32_Q31_e906p(a, b))

#undef SATURATE16
static OPUS_INLINE opus_val16 SATURATE16_e906p(opus_val32 a)
{
  opus_val16 __result;

  __asm__(
      "#SATURATE16\n\t"
      "sclip32 %0, %1, 15\n\t"
      : "=r"(__result)
      : "r"(a)
  );
  return __result;
}
#define SATURATE16(a) (SATURATE16_e906p(a))

#undef PSHR32
static OPUS_INLINE opus_val32 PSHR32_e906p(opus_val32 a, opus_val32 shift)
{
  opus_val32 __result;

  __asm__(
      "#PSHR32\n\t"
      "sra.u %0, %1, %2\n\t"
      : "=r"(__result)
      : "r"(a), "r"(shift)
  );
  return __result;
}
#define PSHR32(a, shift) (PSHR32_e906p(a, shift))
/*
#undef VSHR32
static OPUS_INLINE opus_val32 VSHR32_e906p(opus_val32 a, opus_val32 shift)
{
  opus_val32 __result;

  __asm__(
      "#VSHR32\n\t"
      "sub %0, x0, %2\n\t"
      "kslraw %0, %1, %0\n\t"
      : "+r"(__result)
      : "r"(a), "r"(shift)
  );
  return __result;
}
#define VSHR32(a, shift) (VSHR32_e906p(a, shift))*/
#undef SROUND16
#define SROUND16(x,a) EXTRACT16(SATURATE16(PSHR32(x,a)));

#undef MAC16_16
static OPUS_INLINE opus_val32 MAC16_16_e906p(opus_val32 c, opus_val16 a, opus_val16 b)
{
  __asm__(
      "#MAC16_16\n\t"
      "kmabb %0, %2, %1\n\t"
      : "+r"(c)
      : "r"(a), "r"(b)
  );
  return c;
}
#define MAC16_16(c, a, b) (MAC16_16_e906p(c, a, b))

#undef MAC16_32_Q15
static OPUS_INLINE opus_val32 MAC16_32_Q15_e906p(opus_val32 c, opus_val16 a, opus_val32 b)
{
  __asm__(
      "#MAC16_32_Q15\n\t"
      "kmmawb2 %0, %2, %1\n\t"
      : "+r"(c)
      : "r"(a), "r"(b)
  );
  return c;
}
#define MAC16_32_Q15(c, a, b) (MAC16_32_Q15_e906p(c, a, b))

#undef MAC16_32_Q16
static OPUS_INLINE opus_val32 MAC16_32_Q16_e906p(opus_val32 c, opus_val16 a, opus_val32 b)
{
  __asm__(
      "#MAC16_32_Q16\n\t"
      "kmmawb %0, %2, %1\n\t"
      : "+r"(c)
      : "r"(a), "r"(b)
  );
  return c;
}
#define MAC16_32_Q16(c, a, b) (MAC16_32_Q16_e906p(c, a, b))
#endif